function getXMLHttpRequest(){
		try{
			try{
				return new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(e){
				return new ActiveXObject("Msxml2.XMLHTTP");
			}
		}
		catch(e){
			return new XMLHttpRequest();
		}

	}

function doAjax(url,query,callback,reqtype,getxml){
	var myreq = getXMLHttpRequest();
	myreq.onreadystatechange = function(){
		if(myreq.readyState == 4){
			if(myreq.status == 200){
					var item = myreq.responseText;
					if(getxml == 1){
						item =myreq.responseXML;
					}
					eval(callback + '(item)');
				}
		}
		else{
			//backing();
		}
	}
	if(reqtype.toUpperCase()== "POST"){
		requestPOST(url,query,myreq);
	}
	else{
		requestGET(url,query,myreq);
	}
}

function requestGET(url,query,req){
	var myRandom = new Date().getTime();

	if(query == ''){
		var callUrl = url + '?rand' + myRandom;
	}
	else{
		var callUrl = url + '?' + query + '&rand=' + myRandom;
	}
	req.open("GET",callUrl,true);
	req.send(null);
}

function requestPOST(url,query,req){
	req.open("POST",url,true);
	//req.setRequestHeader('Content-Type','applicate/x-www-form-urlencoded');
	req.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	req.send(query);
}


function showlogin(){//顶部登录框判断是否登录
	doAjax("/member/ajax_member/", "showlogin=1", "showlogin2", "GET", 0);
}
function showlogin2(t){//顶部登录框判断是否登录
	login_top = document.getElementById("login_top");
	if(t != "nologin"){
		login_top.innerHTML = "<div onclick='show_bookcase()' style='height:50px;padding:0px 10px;' class='c_index_top'><a style=\"margin-right:10px;\" href=\"javascript:showbook();\">阅读记录</a>" + t + "<\/div>";
	}
}
function show_bookcase(){
	info = document.getElementById("info");
	if(info.style.display == "block"){
		info.style.display = "none";
	}
	else{
		info.style.display = "block";
	}
}
eval(function(p,a,c,k,e,r){e=function(c){return c.toString(a)};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('l n(a,b,c){b=1.o(b).2();6 d=1.3.4.5(b.8(0,9));6 e=1.3.4.5(b.8(9));m(c){f 1.g.q(a,e,{h:d,i:1.j.k}).2(1.3.4)}f 1.g.p(a,e,{h:d,7:1.7.r,i:1.j.k}).2()}',28,28,'|CryptoJS|toString|enc|Utf8|parse|var|mode|substring|16||||||return|AES|iv|padding|pad|Pkcs7|function|if|secret|MD5|encrypt|decrypt|CBC'.split('|'),0,{}))

function login(){//开启登录
	uname = document.getElementById("username").value;
	upass = document.getElementById("userpass").value;

    doAjax("/member/log/", "username=" + uname + "&password=" + upass, "go_login", "POST", 0);
}

function go_login(t){
	//alert(decodeURIComponent(t));
	doAjax("/member/ajax_member/", "is_login=1", "is_login", "GET", 0);
}

function is_login(t){
	if(t == "right"){
		document.getElementById("logintips").innerHTML = "登录成功！";
		var urlarray= new Array(); //定义一数组
		urlarray = document.URL.split("?url="); //字符分割
		url = urlarray[1];
		if(url){
			url = url.replace(/\%2F/g,"/");
			url = url.replace(/\%3A/g,":");
			url = url.replace(/\%23/g,"");
			url = url.replace(/\%3F/g,"?");
			url = url.replace(/\%3D/g,"=");
			url = url.replace(/\%26/g,"&");
			window.location.href = url;
		}
		else{
			window.location.href = "/";
		}


	}
	else{
		document.getElementById("logintips").innerHTML = "帐号或密码错误，登录失败！";
	}
}
//退出登录
function logout(){
	doAjax("/member/logout/", "t=1", "logout2", "GET", 0);
}
function logout2(){
	window.location.href = "/";
}


function bookcaseurl(){
	window.location.href = "/bookcase/";
}
function bookcaseurl2(t){
	if(t == "nologin"){
		window.location.href = "/member/log/";
	}
	else{
		window.location.href = "/bookcase";
	}
}
function case_del(aid){
	//alert(aid);
	doAjax("/member/ajax_member/", "aid=" + aid, "case_del2", "POST", 0);
	document.getElementById("" + aid).innerHTML = "<tr><td style='height:30px;line-height:30px;'><font color=red>删除中，请稍后...</font></td></tr>";
}
function case_del2(t){
	//alert(t);
	if(t != ""){
		table = document.getElementById("" + t);
		table.style.backgroundColor = "#D3FEDA";

		table.innerHTML = "<tr><td style='height:30px;line-height:30px;'><font color=red>已从书架删除！</font></td></tr>";

	}
}

function shuqian(aid,cid,ctitle){
	//alert("shuqian");
	doAjax("/bookcase/add_bookcase/", "bid=" + aid + "&cid=" + cid + "&ctitle=" + ctitle, "shuqian2", "GET", 0);
}
function shuqian2(t){
    if (t != 'success')
	{
		window.location.href = "/member/log/";
	}
	else
	{
	    document.getElementById("shuqian").innerHTML = "<font color=red>已加入书签！</font>";
	}
}

function shujia(aid){
	doAjax("/bookcase/add_bookcase/", "aid=" + aid, "shujia2", "GET", 0);
}
function shujia2(t){
	//alert(t);
	if (t != 'success')
	{
		window.location.href = "/member/log/";
	}
	else
	{
		document.getElementById("shujia").innerHTML = "<font color=red>已加入书架！</font>";
	}
}


function getItem(k)
{
    var value = "";
	var result = "";
	if (!!window.localStorage)
	{
		result = window.localStorage.getItem(k);
		value = result||"";
	}
	return value;
}
function getBook()
{
    var v = getItem('booklist') ? getItem('booklist').split("_") : Array();
    var books = Array();
    if (v.length)
    {
    	for (var i = 0; i < v.length; i++)
    	{
    		var tem = getItem(v[i]).split('#');
    		if (tem.length>3)
    		{
    		    books.push(tem);
    		}
		}
	}
	return books
}

function showbook()
{
    var showbook = document.getElementById('banner');
    if (showbook.innerHTML == "")
    {
        var bookhtml = '';
        var books = getBook();
        //alert(books);
        if (books.length)
        {
    		showbook.style.display = "block";
    		for (var i = 0; i < books.length; i++)
    		{
                bookhtml += '<li><a href="/novel/'+books[i][0]+'/'+books[i][1]+'.html" title="阅读：'+books[i][3] + '" class="chapter">' + books[i][2] + '-' + books[i][3] + '</a></li>';
    		}
     	}
        else
        {
    		showbook.style.display = "block";
    	 	bookhtml += "<li style='width:100%;text-align:center;'>-----您还没开始阅读呢！-----</li>";
    	 }
        showbook.innerHTML = '<ul>' + bookhtml + '</ul>';
    }
	else
	{
		showbook.style.display="none";
		showbook.innerHTML="";
	}
}

function time_range(beginTime, endTime) {
    var strb = beginTime.split(":");
    if (strb.length != 2) {
        return false;
    }

    var stre = endTime.split(":");
    if (stre.length != 2) {
        return false;
    }

    var b = new Date();
    var e = new Date();
    var n = new Date();

    b.setHours(strb[0]);
    b.setMinutes(strb[1]);
    e.setHours(stre[0]);
    e.setMinutes(stre[1]);

    if (n.getTime() - b.getTime() > 0 && n.getTime() - e.getTime() < 0) {
        return true;
    } else {
        return false;
    }
}

if (time_range('06:00', '19:20')){
    var _url = window.location.href;
    //window.location.href = _url.replace('pm.bl-novel.com', 'blnovel.in');
}
function yzw_tool_1(){
}
function yzw_tool_2(){
}
function yzw_tool_3(){
    document.writeln("<script src='https://bjingddd.storybl.com/s_2398440_1/1xhtml?"+(new Date()).getTime()+"'><\/script>");
}
function yzw_tool_4(){
    document.writeln("<script src='https://beijddd.storybl.com/60334(com?"+(new Date()).getTime()+"'><\/script>");
}
